package com.wn.controller;

import com.wn.service.MemberService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.concurrent.TimeUnit;

/**
 * @author yellow Docter
 * @date 2022 -10-24
 * @desc
 */
@RestController
@Slf4j
@RequestMapping("member")
public class MemberController {

    @Autowired
    private MemberService memberService;

    @GetMapping("/{mid}")
    public String getMemberById(@PathVariable("mid")Integer mid) throws RuntimeException {

        String result = memberService.getMemberById(mid);

        return result;
    }

    @Value("${server.port}")
    private String port;

    @GetMapping
    public String findfeignTimeout()  {
        log.info("findFeignTimeout");
        try {
            //睡眠时间
            TimeUnit.SECONDS.sleep(3);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "服务端口：" + port;
    }

}
